<template>
  <div class="app-container">
    <div class="project-search">
      <el-form :model="form" label-width="auto" :inline="true">
        <el-form-item>
          <el-input placeholder="请输入大屏名称" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleSearch">
            搜索
          </el-button>
        </el-form-item>
      </el-form>
    </div>

    <div class="project-main">
      <div v-for="item in 8" :key="item" class="list">
        <div class="list-common">
          <img src="@/assets/images/project.png">
          <div class="hover-buttons">
            <el-button class="view-button" @click="handleView">
              查看
            </el-button>
            <el-button class="edit-button" @click="handleEdit">
              编辑
            </el-button>
          </div>
        </div>
        <div class="list-footer">
          <span class="project-name" :title="'项目名称'.repeat(item)">项目名称项目名称项目名称项目名称项目名称项目名称项目名称项目名称项目名称</span>
          <span>预览</span>
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.project-search {
  width: 100%;
  height: 50px;
  background-color: #fff;
  display: flex;
  justify-content: flex-end;
  padding: 10px 0;
}

.project-main {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}

.list {
  width: 250px;
  height: 200px;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;

  .list-common {
    height: 150px;
    position: relative;

    img {
      width: 100%;
      height: 100%;
    }

    .hover-buttons {
      display: none;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      gap: 10px;
    }

    &:hover .hover-buttons {
      display: flex;
    }
  }

  .list-footer {
    height: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;

    .project-name {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 50px; /* 确保宽度不超过容器宽度 */
      display: inline-block; /* 使元素可以应用 title 属性 */
    }

    span {
      font-size: 12px;
      color: #999;
    }
  }
}
</style>
